package com.train.forum.utils;

import com.train.forum.pojo.enums.ResponseEnum;
import lombok.Data;

@Data
public class Rs {
    /**
     * 错误
     *
     * @param msg 消息
     * @return {@link  R}
     */
    public static R error(String msg){
        return new  R().setSuccess(false).setMsg(msg);
    }
    public static  R error(){
        return new  R().setSuccess(false);
    }
    public static  R error(int code, String msg){
        return new  R().setMsg(msg).setCode(code);
    }
    public static  R error(ResponseEnum responseEnum){
        return new  R().setMsg(responseEnum.getMessage()).setCode(responseEnum.getCode());
    }
    /**
     * 成功
     *
     * @param msg 消息
     * @return {@link  R}
     */
    public static  R success(String msg){
        return new  R().setSuccess(true).setMsg(msg);
    }
    public static  R success(){
        return new  R().setSuccess(true);
    }
    public static  R successData(String data){
        return new  R().setSuccess(true).setData(data);
    }
    public static <T>  R<T> success(T data){
        return new  R<T>(data);
    }
    public static  R success(int code, String message){
        return new  R().setCode(code).setMsg(message);
    }


}
